//
//  LDXVisitorTableViewController.swift
//  微博
//
//  Created by 吕东星 on 17/3/30.
//  Copyright © 2017年 lddongxing. All rights reserved.
//

import UIKit

//访客视图控制器
class LDXVisitorTableViewController: UITableViewController {

    var islogin:Bool = false
    var visitorView :LDXVisitorView?
    
    
    override func loadView() {
        if islogin {
            super.loadView()
//          view.backgroundColor = UIColor.darkGray
        }else{
             visitorView = LDXVisitorView()
            // 代理方法
//            visitorView?.delegate = self
            // 闭包
            visitorView?.loginClosure = { [weak self] in
            self?.enterOAuth()
            }
           view = visitorView
            setNavUI()
        }
    }
    
    

    func setNavUI() {
        // 设置button
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册",target:self,action:#selector(registerButtonAction))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录",target:self,action:#selector(loginButtonAction))
        
    }
    
    func registerButtonAction()  {
        enterOAuth()
    }
    
    func loginButtonAction()  {
        enterOAuth()
    }

    override func viewDidLoad() {
        super.viewDidLoad()

       
    }
    
    // 进入OAuth控制器
   private func enterOAuth()  {
    let oAuthVC = LDXOAuthViewController()
    let nav = LDXNavViewController(rootViewController: oAuthVC)
    self.present(nav, animated: true, completion: nil)
    
    }
    
    
    
}

extension LDXVisitorTableViewController: LDXVisitorViewDelegate{
    func loginOpration() {
       
    }
}
